package com.hui.web.servlet.roomServlet;

import com.hui.bean.RecordBean;
import com.hui.service.IRecordService;
import com.hui.service.impl.RecordServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "RoomRecordIndexServlet",urlPatterns = "/room/record/index")
public class RoomRecordIndexServlet extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        String roomId = request.getParameter("roomId");
        IRecordService recordService=new RecordServiceImpl();
        List<RecordBean> recordBeans = recordService.getRecordBeanListByRoomId(Integer.parseInt(roomId));
        System.out.println(recordBeans);
        request.setAttribute("records",recordBeans);
        request.setAttribute("roomId",roomId);
        request.getRequestDispatcher("/page/room/roomEqp.jsp").forward(request, response);
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
